package tlcn.business;

import java.util.ArrayList;
import tlcn.app.R;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

public class ListDateShopAdapter extends ArrayAdapter<String> {

	Context context; 
	ArrayList<String> listDate;
	public ArrayList<Boolean> listCheck;
	int resource;
	public ListDateShopAdapter(Context context, int resource,ArrayList<String> list) {
		super(context, resource,list);
		this.context=context;
		this.resource=resource;
		listDate=list;
		listCheck= new ArrayList<Boolean>();
		for (int i=0;i<list.size();i++) {
			listCheck.add(false);
		}
	}
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		convertView=View.inflate(context, resource, null);
		TextView txtDateOfShop=(TextView) convertView.findViewById(R.id.txtDateOfShop);
		txtDateOfShop.setText(listDate.get(position));
		CheckBox checkBox=(CheckBox) convertView.findViewById(R.id.checkBox);
		checkBox.setChecked(listCheck.get(position));
		checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				listCheck.set(position, isChecked);
			}
		});
		return convertView;
	}
}
